﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System;
using WorldMapNew;
using Random = UnityEngine.Random;

public class MapChunckTrafficLight : MonoBehaviour
{
    public Transform[] light1;
    public Transform[] light2;
    public int state = -1; // 0 green 1 yellow 2 red

    public int nodeId = -1;
    public int direction = 0;

    public void UpdateShow(int paraState)
    {
        bool bChangeState = paraState != state;
 
        if (bChangeState)
        {
            state = paraState;
            for (int i = 0;i < light1.Length; i++)
            {
                if(light1[i])
                light1[i].gameObject.SetActive(i == state);
            }
            for (int i = 0; i < light2.Length; i++)
            {
                if (light2[i])
                    light2[i].gameObject.SetActive(i == state);
            }
        }
    }

    public void OnReset()
    {
        state = -1; 
        nodeId = -1;
        direction = 0;
    }
}
